<?php

use Intervention\Image\Facades\Image;

function upload($request,$filename,$path){
        $filePath=$request->file($filename)->storePublicly($path);
        return $filePath;
}
function thumb($filePath){
    $img=Image::make('./storage/'.$filePath);//            ImageManagerStatic::make()
    $img->fit(100);
    $path=substr($filePath,0,strrpos($filePath,'/'));
    $name=substr($filePath,strrpos($filePath,'/')+1);
    $img->save('./storage/'.$path.'/thumb_'.$name);
    $thumb_name=ltrim($img->dirname,'.').'/'.$img->basename;
    return $thumb_name;
}